/**
 * 
 */
package com.cipe.cmrs.controllers;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.cipe.cmrs.model.Donorawardstatus;
import com.cipe.cmrs.service.DonorawardstatusService;

/**
 * @author Incepio
 *
 */
@Controller
public class DonorawardstatusController extends BaseController {

	/**
	 * 
	 */
	private static final long		serialVersionUID	= -3823562098119817733L;
	@Autowired
	private DonorawardstatusService	donorawardstatusService;

	@RequestMapping("/secure/saveDonorawardstatus.do")
	public String SaveDonorawardstatus(@ModelAttribute("donorawardstatus") Donorawardstatus donorawardstatus, BindingResult result, Model model, HttpServletRequest request) {
		try {
			donorawardstatus = donorawardstatusService.saveDonorawardstatus(donorawardstatus, getUserId(request));
			saveMessage(request, getText("editDonorawardstatus.message.success"));
		} catch (Exception e) {
			logger.error(getText("error.transaction"), e);
			saveError(request, getText("error.transaction"));
		}
		model.addAttribute("donorawardstatus", donorawardstatus);
		return "editDonorawardstatus";
	}

	@RequestMapping("/secure/showAddDonorawardstatus.do")
	public String showAddDonorawardstatus(Model model) {
		model.addAttribute("donorawardstatus", new Donorawardstatus());
		return "editDonorawardstatus";
	}

	@RequestMapping("/secure/showDonorawardstatusList.do")
	public String showDonorawardstatusList(Model model) {
		model.addAttribute("donorawardstatuses", donorawardstatusService.findAll());
		return "donorawardstatusList";
	}

	@RequestMapping("/secure/showEditDonorawardstatus.do")
	public String showEditDonorawardstatus(@RequestParam Integer id, Model model) {
		model.addAttribute("donorawardstatus", donorawardstatusService.findById(id));
		return "editDonorawardstatus";
	}
}
